/** \file indi-iidc.cpp
    \brief IIDC - DCAM cameras driver for INDI.
    \author Blaise-Florentin Collin
*/

#include <memory>

#include "Cindi_iidc.hpp"

std::auto_ptr<Cindi_iidc> indi_iidc(0);

/**************************************************************************************
** Initialize indi-iidc object
***************************************************************************************/
void ISInit()
{
 static int isInit=0;
 if (isInit)
  return;
 if (indi_iidc.get() == 0)
 {
     isInit = 1;
     indi_iidc.reset(new Cindi_iidc());
 }
}

/**************************************************************************************
** Return properties of device.
***************************************************************************************/
void ISGetProperties (const char *dev)
{
 ISInit();
 indi_iidc->ISGetProperties(dev);
}

/**************************************************************************************
** Process new switch from client
***************************************************************************************/
void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
 ISInit();
 indi_iidc->ISNewSwitch(dev, name, states, names, n);
}

/**************************************************************************************
** Process new text from client
***************************************************************************************/
void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
{
 ISInit();
 indi_iidc->ISNewText(dev, name, texts, names, n);
}

/**************************************************************************************
** Process new number from client
***************************************************************************************/
void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
 ISInit();
 indi_iidc->ISNewNumber(dev, name, values, names, n);
}

/**************************************************************************************
** Process new blob from client
***************************************************************************************/
void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
{
    ISInit();
    indi_iidc->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, n);
}

/**************************************************************************************
** Process snooped property from another driver
***************************************************************************************/
void ISSnoopDevice (XMLEle *root)
{
  INDI_UNUSED(root);
}


Cindi_iidc::Cindi_iidc()
{
}

/**************************************************************************************
** Client is asking us to establish connection to the device
***************************************************************************************/
bool Cindi_iidc::Connect()
{
    IDMessage(getDeviceName(), "indi-iidc connected successfully!");
    return true;
}

/**************************************************************************************
** Client is asking us to terminate connection to the device
***************************************************************************************/
bool Cindi_iidc::Disconnect()
{
    IDMessage(getDeviceName(), "indi-iidc disconnected successfully!");
    return true;
}

/**************************************************************************************
** INDI is asking us for our default device name
***************************************************************************************/
const char* Cindi_iidc::getDefaultName()
{
    return "indi-iidc";
}
